/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.web.gwt.basics.client.log;

/**
 * this interface allow the application to display logs.
 */
public interface Logger
{

  /**
   * the differents log levels.
   */
  public class Level
  {
    /**
     * the priority value. The greater the priority the greater the importance
     * of the message.
     */
    private final transient int priority;



    /**
     * constructor.
     * 
     * @param priority
     *          the priority value
     */
    private Level(final int priority)
    {
      this.priority = priority;
    }

    /**
     * the lowest log level.
     */
    public static final Level ALL = new Level(0);

    /**
     * trace log level.
     */
    public static final Level TRACE = new Level(1);

    /**
     * debug log level.
     */
    public static final Level DEBUG = new Level(2);

    /**
     * info log level.
     */
    public static final Level INFO = new Level(3);

    /**
     * info log level.
     */
    public static final Level WARN = new Level(4);

    /**
     * error log level.
     */
    public static final Level ERROR = new Level(5);

    /**
     * fatal log level.
     */
    public static final Level FATAL = new Level(6);

    /**
     * the highest log level.
     */
    public static final Level OFF = new Level(7);



    /**
     * returns wether a logger of this level must log events of the other level.
     * 
     * @param other
     *          the other level
     * @return <code>true</code> if a logger of this level must log events of
     *         the other level.
     */
    public boolean mustLog(final Level other)
    {
      return priority <= other.priority;
    }



    /**
     * returns the priority of the {@link Logger}.
     * 
     * @return the priority
     */
    public int getPriority()
    {
      return priority;
    }
  }



  /**
   * set the level of this logger. A logger will log all message of priority
   * greater or equals of its level.
   * 
   * @param level
   *          the level to set
   */
  public void setLevel(Level level);



  /**
   * log a message at the given level.
   * 
   * @param message
   *          the message to log
   * @param level
   *          the level of the message
   */
  public void log(String message, Level level);



  /**
   * log a message at the trace level.
   * 
   * @param message
   *          the message to log
   */
  public void trace(String message);



  /**
   * log a message at the debug level.
   * 
   * @param message
   *          the message to log
   */
  public void debug(String message);



  /**
   * log a message at the info level.
   * 
   * @param message
   *          the message to log
   */
  public void info(String message);



  /**
   * log a message at the warn level.
   * 
   * @param message
   *          the message to log
   */
  public void warn(String message);



  /**
   * log a message at the error level.
   * 
   * @param message
   *          the message to log
   */
  public void error(String message);



  /**
   * log a message at the fatal level.
   * 
   * @param message
   *          the message to log
   */
  public void fatal(String message);
}
